#ifndef _VN_EVENT_H_
#define _VN_EVENT_H_

#include <functional>
#include "..\Generic\GameTime.h"

namespace vn
{
	class Event
	{
	public:
		Event(const std::function<void()> p_function, float p_targetTime) : m_function(p_function), m_targetTime(p_targetTime), m_elapsedTime(0.0f), m_destroy(false) {}
		virtual ~Event(void)
		{
			int p = 0;
		}

		void update(const GameTime& p_gameTime)
		{
			m_elapsedTime = std::min(m_elapsedTime + p_gameTime.deltaTime(), m_targetTime);
			if (m_elapsedTime >= m_targetTime && !m_destroy)
			{
				m_function();
				m_destroy = true;
			}
			
		}
		const bool destroy() const { return m_destroy; }

	protected:
		std::function<void()> m_function;
		float m_elapsedTime;
		float m_targetTime;
		bool m_destroy;
	};
}

#endif // _VN_EVENT_H_